import requests
import datetime


def timestamp_to_date(timestamp_ms, timezone_offset=8):
    """
    将毫秒级时间戳转换为指定时区的日期字符串（YYYY-MM-DD）

    参数:
    timestamp_ms (int): 毫秒级时间戳
    timezone_offset (int): 时区偏移量（UTC+时区），默认为北京时间(UTC+8)

    返回:
    str: 格式化的日期字符串
    """
    # 将毫秒转换为秒
    timestamp_sec = timestamp_ms / 1000

    # 创建 UTC 时间对象
    utc_time = datetime.datetime.utcfromtimestamp(timestamp_sec)

    # 计算目标时区的时间
    target_time = utc_time + datetime.timedelta(hours=timezone_offset)

    # 格式化为 YYYY-MM-DD
    return target_time.strftime('%Y-%m-%d')



cookies = {
    'JSESSIONID': '94CC4C22D486D9A6B1CD7979FB67EF98',
    'tempTokenKey': 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiLnhormr4UiLCJhdWQiOiI5RTEwNTlDOTMzNUQ0QzdDQjhEQzc0MDBEMDNBRUNGQiIsInNlcnZlciI6Imh0dHA6Ly81OS4yMTUuMjA2LjE4OC9sb2dpbi8iLCJyb2xlIjoiUk9MRV9BUkVBLFJPTEVfV0lORE9XIiwiaXNJbml0aWFsUGFzc3dvcmQiOiIwIiwicmVnaW9uTmFtZSI6Iui0teW3nuecgSIsImluZHVzdHJ5IjpudWxsLCJhcHBDb2RlIjoiZGdvdi1wb3J0YWwiLCJvcmdhbk5hbWUiOiLmlrDov5vkurrlkZgiLCJyZWdpb25Db2RlIjoiNTIwMDAwIiwiaW5kdXN0cnlMaXN0IjpudWxsLCJvcmdhbkNvZGUiOiI1MjAwMDAyMDE3MDIxNjEwMDUzMDAwMDUwNyIsImV4cGlyYXRpb25UaW1lIjoyMiwiZ3JhZGUiOiIyIiwic3RhdHVzIjoiMSIsImlzcyI6Imluc3B1ciIsImlhdCI6MTc1MjQ1NjYyNSwiZXhwIjoxNzUyNDg1NDI1fQ.TZmExseIxkFEsaOOEtDndAbsUxHo6QbqZBaejTpudTQLdrgW9epwNSgV-7K_-aoDQiYoGI05infPUOdLdG2O7w',
    'userInfoKey': '{%22role%22:%22ROLE_AREA%2CROLE_WINDOW%22%2C%22isInitialPassword%22:%220%22%2C%22regionName%22:%22%E8%B4%B5%E5%B7%9E%E7%9C%81%22%2C%22appCode%22:%22dgov-portal%22%2C%22organName%22:%22%E6%96%B0%E8%BF%9B%E4%BA%BA%E5%91%98%22%2C%22regionCode%22:%22520000%22%2C%22phone%22:%22384d53fa06a4844cfd54260b048c33e9%22%2C%22organCode%22:%2252000020170216100530000507%22%2C%22expirationTime%22:22%2C%22name%22:%221342b48e6f8f39ea7ba36accc05b61a8%22%2C%22id%22:%229E1059C9335D4C7CB8DC7400D03AECFB%22%2C%22email%22:%223f9980534589201ab2c5f2481db36392%22%2C%22username%22:%2247d57692a252657367001b6a2ff35333%22%2C%22status%22:%221%22%2C%22isWeakPwd%22:%220%22}',
    'pwdState': 'true',
    'inspurRoleKey': 'ROLE_AREA',
    'windowId': '0B7CA12E92004E0ABCA9EB88F0A792E4',
    'James_cookie_sYQDUGqqzHtheme': 'custom',
}

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:139.0) Gecko/20100101 Firefox/139.0',
    'Accept': 'application/json, text/javascript, */*; q=0.01',
    'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
    # 'Accept-Encoding': 'gzip, deflate',
    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
    'X-Requested-With': 'XMLHttpRequest',
    'Origin': 'http://59.215.206.188',
    'Connection': 'keep-alive',
    'Referer': 'http://59.215.206.188/zhslzy/accept/worktodolist/todoFinishIndex',
    # 'Cookie': 'JSESSIONID=94CC4C22D486D9A6B1CD7979FB67EF98; tempTokenKey=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiLnhormr4UiLCJhdWQiOiI5RTEwNTlDOTMzNUQ0QzdDQjhEQzc0MDBEMDNBRUNGQiIsInNlcnZlciI6Imh0dHA6Ly81OS4yMTUuMjA2LjE4OC9sb2dpbi8iLCJyb2xlIjoiUk9MRV9BUkVBLFJPTEVfV0lORE9XIiwiaXNJbml0aWFsUGFzc3dvcmQiOiIwIiwicmVnaW9uTmFtZSI6Iui0teW3nuecgSIsImluZHVzdHJ5IjpudWxsLCJhcHBDb2RlIjoiZGdvdi1wb3J0YWwiLCJvcmdhbk5hbWUiOiLmlrDov5vkurrlkZgiLCJyZWdpb25Db2RlIjoiNTIwMDAwIiwiaW5kdXN0cnlMaXN0IjpudWxsLCJvcmdhbkNvZGUiOiI1MjAwMDAyMDE3MDIxNjEwMDUzMDAwMDUwNyIsImV4cGlyYXRpb25UaW1lIjoyMiwiZ3JhZGUiOiIyIiwic3RhdHVzIjoiMSIsImlzcyI6Imluc3B1ciIsImlhdCI6MTc1MjQ1NjYyNSwiZXhwIjoxNzUyNDg1NDI1fQ.TZmExseIxkFEsaOOEtDndAbsUxHo6QbqZBaejTpudTQLdrgW9epwNSgV-7K_-aoDQiYoGI05infPUOdLdG2O7w; userInfoKey={%22role%22:%22ROLE_AREA%2CROLE_WINDOW%22%2C%22isInitialPassword%22:%220%22%2C%22regionName%22:%22%E8%B4%B5%E5%B7%9E%E7%9C%81%22%2C%22appCode%22:%22dgov-portal%22%2C%22organName%22:%22%E6%96%B0%E8%BF%9B%E4%BA%BA%E5%91%98%22%2C%22regionCode%22:%22520000%22%2C%22phone%22:%22384d53fa06a4844cfd54260b048c33e9%22%2C%22organCode%22:%2252000020170216100530000507%22%2C%22expirationTime%22:22%2C%22name%22:%221342b48e6f8f39ea7ba36accc05b61a8%22%2C%22id%22:%229E1059C9335D4C7CB8DC7400D03AECFB%22%2C%22email%22:%223f9980534589201ab2c5f2481db36392%22%2C%22username%22:%2247d57692a252657367001b6a2ff35333%22%2C%22status%22:%221%22%2C%22isWeakPwd%22:%220%22}; pwdState=true; inspurRoleKey=ROLE_AREA; windowId=0B7CA12E92004E0ABCA9EB88F0A792E4; James_cookie_sYQDUGqqzHtheme=custom',
    'Priority': 'u=0',
}

params = {
    'isAllDeal': '',
}

data={
    "signstate": "94,95,",
    "_search": "true",
    "nd": "1752457406620",
    "rows": "100",
    "page": "1",
    "sidx": "RECEIVE_TIME",
    "sord": "desc",
    "receivenum": "",
    "applicant": "",
    "itemname": "",
    "getbarcode": "",
    "submitTime": "2025-01-01 至 2025-12-31",
    "submitTime_start": "2025-01-01",
    "submitTime_end": "2025-12-31",
    "curState": "",
    "regionName": "赤水市,赤水市天台镇,赤水市复兴镇,赤水市长沙镇,赤水市石堡乡,赤水市丙安镇,赤水市元厚镇,赤水市大同镇,赤水市葫市镇,赤水市宝源乡,赤水市长兴镇,赤水市官葫镇,赤水市白云乡,赤水市葫市镇,赤水市金华街道,赤水市文华街道,赤水市两河口镇,赤水市中心街道",
    "regionCode": "520381,52038104,52038102,52038103,52038105,52038106,52038107,52038108,52038109,52038110,52038111,52038112,52038113,52038114,52038115,52038116,52038117,52038118"
}
response = requests.post(
    'http://59.215.206.188/zhslzy/accept/worktodolist/querytodofinish',
    params=params,
    cookies=cookies,
    headers=headers,
    data=data,
).json()
for i in response['rows']:
    # print(i)
    print(i['cell']['RECEIVE_NUMBER'],i['cell']['APPLICANT'],i['cell']['ITEM_NAME'],i['cell']['ORG_NAME'],timestamp_to_date(i['cell']['RECEIVE_TIME']))